<extend name="Base/common"/>
<!--<script type="text/javascript" src="/SG_Shopwechat/Public/Home/js/iscroll.js"></script>-->
<block name="TITLE"><title>采购申请</title></block>
<block name="body" >
    <header data-am-widget="header" class="am-header am-header-default am-header-fixed">
        <div class="am-header-left am-header-nav">
            <a href="{:U('Purchase/index')}" class="">
                <i class="am-header-icon am-icon-home" style="font-size: 40px;"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">
                &nbsp;{$title}
            </a>
        </h1>
    </header>
    <div class="" style="margin-top:10px;">
        <if condition="$id gt 0">
            <form class="am-form am-form-horizontal" action="{:U('List/editpro')}" method="POST">
                <else/>
             <form class="am-form am-form-horizontal" action="{:U('List/newproduct')}" method="POST">
        </if>
            <div class="am-form-group">
                <label for="proName" class="am-u-sm-3 am-form-label">商品名称</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="proName" id="proName" type="text" placeholder="输入商品名称" value="{$pro.proName}" required readonly/>
                </div>
                <input type="hidden" name="batch" value="{$batch}">
            </div>

            <div class="am-form-group">
                <label for="spec" class="am-u-sm-3 am-form-label">单箱规格</label>
                <div class="am-u-sm-3">
                    <input class="am-form-field" name="spec" id="spec" type="hidden"  placeholder="输入单箱规格" value="{$pro.spec}"/>
                    <input class="" name="head" id="head" type="text" value="{$pro.head}" />
                </div>
                <label for="spec" class="am-u-sm-1 am-form-label">头</label>
                <div class="am-u-sm-3">
                    <input class="" name="jin" id="jin" type="text"  value="{$pro.jin}"/>
                </div>
                <label for="spec" class="am-u-sm-2 am-form-label">斤</label>
            </div>

            <div class="am-form-group">
                <label for="grossWeight" class="am-u-sm-3 am-form-label">总重量</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="grossWeight" id="grossWeight" type="text"  onblur="getNetWeight()" placeholder="输入总重量 斤" value="{$pro.grossWeight}"/>
                </div>
            </div>

            <div class="am-form-group">
                <label for="number" class="am-u-sm-3 am-form-label">采购件数</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="number" id="number" type="text" onblur="getAmount();" placeholder="输入采购件数" value="{$pro.number}"/>
                </div>
            </div>

            <div class="am-form-group">
                <div class="am-u-sm-12">
                    <input type="hidden" name="id" value="{$pro.id}" />
                    <button type="submit" class="am-btn am-btn-primary am-btn-block">提交至采购单</button>
                </div>
            </div>
        </form>
    </div>
</block>
<block name="script">

    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">

        //自动算出 采购总价 （采购总价 ＝ 采购件数 * 采购单价）
        function getAmount(){
            number = $("#number").val();        //采购件数
            price = $("#price").val();          //采购单价
            $("#amount").val(number * price );  //采购总价

            grossWeight = $("#grossWeight").val();        //总重量
            boxheavy = $("#boxheavy").val();              //箱重
            $("#netWeight").val((grossWeight - (number * boxheavy)) / number);  //净重
        }

        //自动算出 净重 （净重 ＝ （总重量 －（采购件数 * 箱重））/ 采购件数）
        function getNetWeight(){
            grossWeight = $("#grossWeight").val();        //总重量
            number = $("#number").val();                  //采购件数
            boxheavy = $("#boxheavy").val();              //箱重
            $("#netWeight").val((grossWeight - (number * boxheavy)) / number);  //净重
        }
    </script>
</block>
